<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags/form" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>java在线网盘系統-后台管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${ctx}/static/layui/css/layui.css" media="all">
    <script src="${ctx}/static/layui/layui.js"></script>
    <script src='${ctx}/js/jquery.min.js'></script>
</head>
<body style="padding:30px;height: 100%;">
<blockquote class="layui-elem-quote" style="text-align: center;">
    密码修改
</blockquote>
<form class="layui-form" action="#" onsubmit="return false;">
    <div class="layui-form-item">
        <label class="layui-form-label">网盘名称</label>
        <div class="layui-input-inline">
            <input type="text" name="username" id="username" required lay-verify="required"
                   placeholder="请输入网盘名称" value="${user.username}"  ${user.username=='admin'?'readonly':''}
                   class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">网盘名称</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">新密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password" id="password" required lay-verify="required" placeholder="请输入密码"
                   autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">字母数字组合</div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-inline">
            <input type="password" name="password2" id="password2" required lay-verify="required" placeholder="请输入密码"
                   autocomplete="off"
                   class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux">字母数字组合</div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" onclick="subForm()">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>


<script>
    //Demo
    function subForm() {
        layui.use(['form', 'layer'], function () {
            var form = layui.form;
            var layer = layui.layer;
            var username = $('#username').val();
            var password = $('#password').val();
            var password2 = $('#password2').val();
            if (username == '') {
                layer.alert("请输入网盘名称");
                return false;
            }
            if (password == '') {
                layer.alert("请输入新密码");
                return false;
            }
            if (password2 == '') {
                layer.alert("请输入确认密码");
                return false;
            }
            if (password2 != password) {
                layer.alert("新密码和确认密码必须保持一致");
                return false;
            }
            //监听提交
            $.post('${ctx}/updatePasswordSubmit', {"newpass": password, "username": username}, function (msg) {
                layer.msg("信息修改成功，下次登录生效", {icon: 1});
            })
            return false;
        });
    }
</script>
</body>
</html>
